package com.xray.netdisk.service.impl;

import com.xray.netdisk.pojo.User;
import com.xray.netdisk.service.UserService;
import com.xray.netdisk.utils.JDBCUtils;

import java.util.List;

/**
 * 用户逻辑实现
 */
public class UserServiceImpl implements UserService {

    @Override
    public User login(String username, String password) {
        List<User> users = JDBCUtils.queryList(User.class,
                "select * from t_user where username=? and password =?",
                username, password);
        if(users.isEmpty()) {
            return null;
        }
        return users.get(0);
    }

    @Override
    public User getUserById(Long userId) {
        List<User> users = JDBCUtils.queryList(User.class,
                "select * from t_user where id =?",
                userId);
        if(users.isEmpty()) {
            return null;
        }
        return users.get(0);
    }
}
